package cn.jhz.learn.blog.vo.article.submit;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
import java.util.List;
import java.util.Optional;


@Setter
@Getter
@ToString
public class ArticleParam {

    @Min(value = 1, message = "无效id!")
    private Integer id;

    @Length(min = 4, max = 8193, message = "无效链接!")
    private String link;

    @Min(value = 1, message = "无效确认!")
    @Max(value = 1, message = "无效确认!")
    private Byte confirm;

//    @Size(min = 1, message = "分支列表为空!")
    private List<@Min(value = 1, message = "无效分支id!")Integer> subfield;

    @NotBlank(message = "无效内容!")
    @Length(min = 1, max = 65535, message = "内容长度无效!")
    private String content;

    @NotBlank(message = "无效标题!")
    @Length(min = 1, max = 100, message = "标题长度无效!")
    private String title;

    @NotNull(message = "类型属性为null!")
    @Min(value = 0, message = "无效类型!")
    @Max(value = 2, message = "无效类型!")
    private Byte type;

    @NotNull(message = "公开属性为null!")
    @Min(value = 0, message = "公开属性无效!")
    @Max(value = 2, message = "公开属性无效!")
    private Byte visibility;

    @NotNull(message = "状态为null!")
    @Min(value = 1, message = "无效状态!")
    @Max(value = 2, message = "无效状态!")
    private Byte status;

    public Optional<String> getLink() {
        return Optional.ofNullable(this.link);
    }

    public Optional<Byte> getConfirm() {
        return Optional.ofNullable(this.confirm);
    }

    public Optional<Integer> getId() {
        return Optional.ofNullable(this.id);
    }

    public Optional<List<Integer>> getSubfield() {
        return Optional.ofNullable(this.subfield);
    }
}
